Initial build-using-dockerfile implementation#59
Initial build-using-dockerfile implementation#59nalind wants to merge 6 commits intocontainers:masterfrom
Conversation
cmd/buildah/build.go
Outdated
| @@ -0,0 +1,136 @@ | |||
| package main | |||
There was a problem hiding this comment.
Should we call this build-using-dockerfile.go for consistency?
Or bud.go?
There was a problem hiding this comment.
bud's a lot less typing, so I'll rename it to that.
cmd/buildah/build.go
Outdated
| var ( | ||
| buildFlags = []cli.Flag{ | ||
| cli.BoolFlag{ | ||
| Name: "quiet", |
cmd/buildah/build.go
Outdated
| Usage: "prefix to prepend to the image name in order to pull the image", | ||
| Value: DefaultRegistry, | ||
| }, | ||
| cli.BoolTFlag{ |
There was a problem hiding this comment.
Docker does this by default. I don't think we need an alternative.
cmd/buildah/build.go
Outdated
| Name: "pull", | ||
| Usage: "pull the image if not present", | ||
| }, | ||
| cli.BoolFlag{ |
There was a problem hiding this comment.
I don't think we should do this either, just do what docker does.
There was a problem hiding this comment.
This defaults to true, and --pull-always defaults to false, like "buildah from" does. I'll note that "docker build"'s --pull is equivalent to --pull-always, so maybe we need to drop --pull from both, and rename --pull-always to --pull?
cmd/buildah/build.go
Outdated
| }, | ||
| cli.StringSliceFlag{ | ||
| Name: "arg", | ||
| Usage: "`argument=value` to supply to the builder", |
There was a problem hiding this comment.
This is used to supply a value for a variable named by an ARG instruction in a Dockerfile, after which the variable's value can be referred to in other instructions, and will be added to the environment list we get when we're told to process a RUN instruction. Renaming this to --build-arg.
cmd/buildah/build.go
Outdated
| Output: output, | ||
| } | ||
|
|
||
| return imagebuildah.BuildDockerfileFromFile(store, options, dockerfiles...) |
There was a problem hiding this comment.
Should this just be BuildDockerfile(...)
imagebuildah/build.go
Outdated
| systemContext *types.SystemContext | ||
| } | ||
|
|
||
| func getSystemContext(signaturePolicyPath string) *types.SystemContext { |
There was a problem hiding this comment.
Should this function be just
systemContext(...)
There was a problem hiding this comment.
fwiw, I prefer keeping the get in the name here.
There was a problem hiding this comment.
I am fine with get, but I think @mrunalp pointed out that there is some kind of GOLANG standard that says this is discouraged. I think golint and goverify used in CRI-O and runc give you errors when you start functions with get.
There was a problem hiding this comment.
Here is the suggested style reference: https://golang.org/doc/effective_go.html#Getters
There was a problem hiding this comment.
Hmm, that's focused more on wrappers for reading and writing object members, but in terms of what it does, it probably makes more sense to call it makeSystemContext().
imagebuildah/build.go
Outdated
| return sc | ||
| } | ||
|
|
||
| func (b *buildahExecutor) Preserve(path string) error { |
There was a problem hiding this comment.
We need to add comments to all externally defined functions. We need to start running golint and govalidate against our code. I have no idea what Preserve does and it seems to be not implemented yet.
There was a problem hiding this comment.
See #62 for adding formatting and style checking to CI. The Preserve method is used to signal the Executor that the path has been marked as part of a volume, which means we need to keep instructions other than an explicit ADD or COPY from modifying anything below that point. The imagebuilder dockerclient implementation uses caching/restoring around its handling of RUN instructions to accomplish this. Adding that.
imagebuildah/build.go
Outdated
| return nil | ||
| } | ||
|
|
||
| func (b *buildahExecutor) Copy(excludes []string, copies ...imagebuilder.Copy) error { |
imagebuildah/build.go
Outdated
| return nil | ||
| } | ||
|
|
||
| func (b *buildahExecutor) Run(run imagebuilder.Run, config docker.Config) error { |
|
BTW This is pretty awesome. |
imagebuildah/build.go
Outdated
| } | ||
|
|
||
| // BuildDockerfile builds an image using instructions from the named file. | ||
| func BuildDockerfileFromFile(store storage.Store, options BuildDockerfileOptions, dockerfile ...string) error { |
There was a problem hiding this comment.
If you change the name to BuildDockerfileFromFile in build.go, you probably want to do the same here.
dda9371 to
d664cbf
Compare
|
Updated:
|
|
LGTM Do we eventually want to turn ImageBuilder to use Buildah? Might want to move this code out of ImageBuilder into Buildah at that point. |
|
Moving the tell-Travis-to-stop-using-1.6 patch to #65 and rebasing before merging. |
|
I think the imagebuilder CLI could be taught to toggle between its current dockerclient Executor and the one we implement here, as @smarterclayton suggested in openshift/imagebuilder#33. We don't yet support all of the options and hooks that the imagebuilder CLI tool wants to be able to specify, but that's fixable. |
|
You should also be able to snip more of the dependency tree that we pull in - let me know if there are changes that need to be done to make the core imagebuilder code not depend on docker dependencies. |
91dbef9 to
2202a41
Compare
| budFlags = []cli.Flag{ | ||
| cli.BoolFlag{ | ||
| Name: "quiet, q", | ||
| Usage: "refrain from announcing build instructions", |
There was a problem hiding this comment.
Should we reverse this and change it to verbose, and then default it to value so we don't announce build instructions?
There was a problem hiding this comment.
I'm not strongly opposed to it, but docker build and imagebuilder output this info by default.
|
☔ The latest upstream changes (presumably e67d2e7) made this pull request unmergeable. Please resolve the merge conflicts. |
|
man pages and bash completions? |
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Vendor openshift/imagebuilder and its dependencies, and pick up new dependencies on golang.org/x/text and github.com/opencontainers/selinux. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Add a build-using-dockerfile command (alias: bud) which uses openshift/imagebuilder to wrap parsing and dispatching, and runc (or another OCI runtime) to handle RUN instructions. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
It's nowhere near exhaustive, but it's a start. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Add completion for build-using-dockerfile and our renaming of the containers/images --no-truncate flag to --notruncate during the CLI overhaul. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
|
Added a man page and updated the bash-completion script. |
| buildah bud - Build an image using instructions from Dockerfiles. | ||
|
|
||
| ## SYNOPSIS | ||
| **buildah** **bud | build-using-dockerfile** [*options* [...]] [**context**] |
There was a problem hiding this comment.
Is the context directory optional?
There was a problem hiding this comment.
I guess it is if you specify a Dockerfile.
There was a problem hiding this comment.
If at least one of the Dockerfiles is a local file, we assume the directory that it's in is the context directory.
Vendor openshift/imagebuilder and its dependencies, and pick up new dependencies on golang.org/x/text and github.com/opencontainers/selinux. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> Closes: #59 Approved by: rhatdan
Add a build-using-dockerfile command (alias: bud) which uses openshift/imagebuilder to wrap parsing and dispatching, and runc (or another OCI runtime) to handle RUN instructions. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> Closes: #59 Approved by: rhatdan
It's nowhere near exhaustive, but it's a start. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> Closes: #59 Approved by: rhatdan
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> Closes: #59 Approved by: rhatdan
Add completion for build-using-dockerfile and our renaming of the containers/images --no-truncate flag to --notruncate during the CLI overhaul. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> Closes: #59 Approved by: rhatdan
|
☀️ Test successful - status-redhatci |
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com> Closes: #59 Approved by: rhatdan
Add a
build-using-dockerfilecommand which usesopenshift/imagebuilderto wrap parsing and handle most of the dispatching, and the logic behind the other subcommands to implement assorted instructions.